"use strict";
cc._RF.push(module, 'f65f54f9ldJl5M9nHo1hIGh', 'GameModel');
// scripts/GameModel.ts

Object.defineProperty(exports, "__esModule", { value: true });
var Config_1 = require("./Config");
var GameModel = /** @class */ (function () {
    function GameModel() {
        this.win = false;
        this._preciseLevel = 19;
        this._dropLevel = 1;
        this._dragLevel = 1;
        this._drawLevel = 1;
        this._tipCount = 1;
        this.selectedModel = 1; //精确 掉落 拖曳
        this.selectedLevel = 18;
        this.getStar = 0;
        this.drawComplete = false;
        this.dragComplete = false;
        this.dropComplete = false;
        this.preciseComplete = false;
        this.completeInfo = [];
        this.drawLevelInfo = [];
    }
    GameModel.prototype.isNull = function (str) {
        if (str != null && str != undefined && str != '' && str != NaN) {
            return false;
        }
        return true;
    };
    GameModel.prototype.readDraw = function () {
        //画线关卡数据
        var drawLevelStr = cc.sys.localStorage.getItem('drawLevelInfo');
        if (!this.isNull(drawLevelStr)) {
            this.drawLevelInfo = [];
            var list = drawLevelStr.split(',');
            for (var i = 0; i < list.length; i++) {
                this.drawLevelInfo.push(parseInt(list[i]));
            }
        }
        else {
            this.drawLevelInfo = [-1];
        }
        for (var m = 0; m < this.drawLevelInfo.length; m++) {
            if (this.drawLevelInfo[m] == -1) {
                this._drawLevel = m + 1;
                break;
            }
        }
        //是否完成
        var lInfo = cc.sys.localStorage.getItem('completeInfo');
        if (!this.isNull(lInfo)) {
            var list = lInfo.split(',');
            for (var i = 0; i < list.length; i++) {
                this.completeInfo.push(parseInt(list[i]));
            }
        }
        else {
            this.completeInfo = [0, 0, 0, 0];
        }
        //提示数量
        var tipStr = cc.sys.localStorage.getItem('tipCount');
        if (!this.isNull(tipStr)) {
            this._tipCount = parseInt(tipStr);
        }
        else {
            this._tipCount = 2;
        }
    };
    GameModel.prototype.saveDraw = function () {
        var s = this.drawLevelInfo.join(',');
        cc.sys.localStorage.setItem('drawLevelInfo', s);
    };
    Object.defineProperty(GameModel.prototype, "preciseLevel", {
        get: function () {
            return this._preciseLevel;
        },
        set: function (value) {
            if (value > Config_1.default.preciseLevels.length - 1) {
                console.log('通关');
                value = 1;
                this.completeInfo[0] = 1;
                cc.sys.localStorage.setItem('completeInfo', this.completeInfo.join(','));
            }
            this._preciseLevel = value;
            cc.sys.localStorage.setItem('preciseLevel', value + '');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(GameModel.prototype, "dragLevel", {
        get: function () {
            return this._dragLevel;
        },
        set: function (value) {
            if (value > Config_1.default.dragLevels.length - 1) {
                console.log('通关');
                // value = 1;
                this.completeInfo[2] = 1;
                cc.sys.localStorage.setItem('completeInfo', this.completeInfo.join(','));
            }
            this._dragLevel = value;
            cc.sys.localStorage.setItem('dragLevel', value + '');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(GameModel.prototype, "dropLevel", {
        get: function () {
            return this._dropLevel;
        },
        set: function (value) {
            if (value > Config_1.default.brickLevels.length - 1) {
                console.log('通关');
                //  value = 1;
                this.completeInfo[1] = 1;
                cc.sys.localStorage.setItem('completeInfo', this.completeInfo.join(','));
            }
            this._dropLevel = value;
            cc.sys.localStorage.setItem('dropLevel', value + '');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(GameModel.prototype, "drawLevel", {
        get: function () {
            return this._drawLevel;
        },
        set: function (value) {
            if (value > Config_1.default.drawLevels.length - 1) {
                console.log('通关');
                //  value = 1;
                this.completeInfo[3] = 1;
                cc.sys.localStorage.setItem('completeInfo', this.completeInfo.join(','));
            }
            this._drawLevel = value;
            //  cc.sys.localStorage.setItem('drawLevel', value + '')
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(GameModel.prototype, "tipCount", {
        get: function () {
            return this._tipCount;
        },
        set: function (value) {
            this._tipCount = value;
            cc.sys.localStorage.setItem('tipCount', value + '');
        },
        enumerable: false,
        configurable: true
    });
    return GameModel;
}());
exports.default = GameModel;

cc._RF.pop();